for (i=1; exists(file:string("/puttest", i,".html"), port:port); i = i+1)
{
if(i > 20)exit(0); # we could not test this server - really strange
}
name = string("/puttest",i,".html");
#display(name, " is not installed\n");
c = crap(length:77, data:"A quick brown fox jumps over the lazy dog");
req = http_put(item:name, port:port, data:c);
send(socket:soc, data:req);
l = recv_line(socket:soc,length:1024);
close(soc);
#display(l);
upload=0;
if (exists(port:port, file:name)) {
upload=1;
security_warning(port:port, protocol:"tcp",
data: string("We could upload the file '",name, "' onto your web server\nThis allows an attacker to run arbitrary code on your server, or set a trojan horse\nSolution : disable this method\nRisk factor : High") );
} else {
#if("yes" >< integrist)
{
if (" 403 " >< l && "PUT" >< allow) {
#display("answer = ", l, "\n");
security_warning(port:port, protocol:"tcp",
data:string("It seems that the PUT method is enabled on your web server\nAlthough we could not exploit this, you'd better disable it\nSolution : disable this method\nRisk factor : High"));
}
}
}
# Leave file for next test (DELETE). Dirty...
if (! upload) { name = NULL; }
if (name)
{
soc = http_open_socket(port);
if(!soc)exit(0);
req = http_delete(item:name, port:port);
send(socket:soc, data: req);
l = recv_line(socket:soc, length:1024);
if (" 200 " >< l) {
e = exists(port:port, file:name);
}
else
e = 1;
if(!e)
security_hole(port:port, protocol:"tcp",
data: string("We could DELETE the file '", name, "'on your web server\nThis allows an attacker to destroy some of your pages\nSolution : disable this method\nRisk factor : High") ) ;
} else {
if (" 403 " >< l && " is disabled " >!< l && "DELETE" >< allow) {
security_warning(port:port, protocol:"tcp",
data:string("It seems that the DELETE method is enabled on your web server\nAlthough we could not exploit this, you'd better disable it\nSolution : disable this method\nRisk factor : Medium"));